#!/usr/local/bin/python
#-*- encoding:utf-8 -*- 
import sys
import os

logFileList = []

def listAllLogFile(logDir):
    if(os.path.isdir(logDir)):
        for f in os.listdir(logDir):
            sub = os.path.join(logDir, f);
            listAllLogFile(sub);
    elif os.path.isfile(logDir):
        logFileList.append(logDir);


def processing(logFile, destLog):
	for line in logFile:
		li = line.strip().split('|');
		queryS = li[1];
		A.add(queryS);

if __name__ == '__main__':
    searchLogDir = '/home/wangshuxin/app_search/log/hispace_search_log/';
    listAllLogFile(searchLogDir);

	A = set();
	for f in logFileList:
		processing(open(f, 'r'), A);
	print len(A);
	destLog = open('format_log', 'w');
	for a in A:
		destLog.write('%s\n' %(a,));
        destLog.close();
